// xc_lshop/shop/order/group/buyinfo.js
var actgroupbill = require('../../model/order_groupbuy')

Page({
  mixins: [require('../../../../xc/mixins/basicMixin')],

  /**
   * 页面的初始数据
   */
  data: {

  },
  //邀请好友
  invite() {
    this.selectComponent("#widgetsshare").showSharefunc();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  xcloaddata: function (options, config) {
    var that = this;
    var updateconfig = {};
    if (config.prothem && config.prothem.detail) {
      var popconfig = config.prothem.popup.proconfig;
      var popCustomStyle = config.prothem.popup.customStyle;
      updateconfig['popconfig'] = popconfig
      updateconfig['popCustomStyle'] = popCustomStyle;
    }
    that.setData(updateconfig)
    var groupid = options.groupid;
    that.getmodel(groupid)
  },
  //获取拼团详情
  getmodel: function (id) {
    var that = this;
    actgroupbill.getmodel(id).then(res => {
      console.log("res")
      console.log(res.obj)
      if (res.status == 1) {
        var obj = res.obj;
        // if (obj['proinfo']['skudata'] && obj['proinfo']['skudata']['stockdata']) {
        //   var stockdata = obj['proinfo']['skudata']['stockdata'];
        //   var minactprice = "";
        //   for (var i in stockdata) {
        //     if (!minactprice || minactprice > stockdata[i].activityprice) {
        //       minactprice = stockdata[i].activityprice
        //     }
        //   }
        //   obj['proinfo']['minactprice'] = minactprice;
        // }
        // if(that.data.memberinfo){
        //   that.changeopstatus(that.data.memberinfo,obj.leaderid)
        // }
        that.setData({
          xcmodel: obj
        })


      }
    })
  },
  afterlogin: function (options, config, userinfo) {
    this.setData({
      member: userinfo
    })
    // var app = getApp()
    // var that = this;

    // app.xc_sys_config.authop.oppower("login").then(function (res) {
    //   var member = app.globalData.member;
    //   var memberinfo=member.memberinfo

    //   var update = {};
    //   update['memberinfo']=memberinfo;
    //   if(options.auth){
    //     if(options.auth=='business' && memberinfo.authority==2){
    //       that.setData({
    //         auth:'business'
    //        })
    //     }
    //   }
    // that.setData({
    //   "member": app.globalData.member
    // })
    // console.log(memberinfo)
    // if (memberinfo.id == that.data.xcmodel.leaderid && that.data.opstatus == "invite") {
    //   update['opstatus'] = 'infor'
    // } else if (memberinfo.id != that.data.xcmodel.leaderid && that.data.opstatus == "infor") {
    //   update['opstatus'] = 'invite'
    // }
    // that.setData(update)
    // if(that.data.xcmodel){
    //   that.changeopstatus(memberinfo,that.data.xcmodel.leaderid)
    // }
    // })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var app = getApp()
    var proinfor=this.data.xcmodel.proinfo
    var sharetitle =proinfor.name
    var shareimg = proinfor.simg
    var sharepath ="/xc_lshop/shop/pro/proinfo?id="+proinfor.id
    if(this.data.member.member_id){
      sharepath =sharepath+'&shareid='+this.data.member.member_id
    }
    return {
      title: sharetitle,
      path: sharepath,
      imageUrl: shareimg
    }
  },
})